package com.zzcoder.mall.common.dto;

import com.zzcoder.mall.data.model.PmsCategory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "分类树节点")
@Data
public class PmsCategoryTreeNode extends PmsCategory {
    @ApiModelProperty(value = "父级分类")
    private PmsCategoryTreeNode parent;

    @ApiModelProperty(value = "子级分类列表")
    private List<PmsCategoryTreeNode> children = new ArrayList<>();

    public PmsCategoryTreeNode() {
    }

    public PmsCategoryTreeNode(PmsCategory category) {
        if (category == null) {
            return;
        }
        this.setId(category.getId());
        this.setCreatedTime(category.getCreatedTime());
        this.setCreatorId(category.getCreatorId());
        this.setLastModifiedTime(category.getLastModifiedTime());
        this.setLastModifierId(category.getLastModifierId());
        this.setName(category.getName());
        this.setParentId(category.getParentId());
        this.setRootId(category.getRootId());
        this.setLevel(category.getLevel());
    }
}
